package o;

import android.content.Context;
import android.content.ContextWrapper;
import android.content.res.AssetManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.Resources.Theme;
import android.os.Build.VERSION;
import android.view.LayoutInflater;
import androidx.annotation.StyleRes;
import o.ah.f;

public class ax extends ContextWrapper {
    private Theme ˊ;
    private Resources ˋ;
    private LayoutInflater ˎ;
    private Configuration ˏ;
    private int ॱ;

    public ax() {
        super(null);
    }

    public ax(Context context, @StyleRes int i) {
        super(context);
        this.ॱ = i;
    }

    public ax(Context context, Theme theme) {
        super(context);
        this.ˊ = theme;
    }

    protected void attachBaseContext(Context context) {
        super.attachBaseContext(context);
    }

    public Resources getResources() {
        return ˏ();
    }

    private Resources ˏ() {
        if (this.ˋ == null) {
            if (this.ˏ == null) {
                this.ˋ = super.getResources();
            } else if (VERSION.SDK_INT >= 17) {
                this.ˋ = createConfigurationContext(this.ˏ).getResources();
            }
        }
        return this.ˋ;
    }

    public void setTheme(int i) {
        if (this.ॱ != i) {
            this.ॱ = i;
            ॱ();
        }
    }

    public int ˎ() {
        return this.ॱ;
    }

    public Theme getTheme() {
        if (this.ˊ != null) {
            return this.ˊ;
        }
        if (this.ॱ == 0) {
            this.ॱ = f.ˊ;
        }
        ॱ();
        return this.ˊ;
    }

    public Object getSystemService(String str) {
        if (!"layout_inflater".equals(str)) {
            return getBaseContext().getSystemService(str);
        }
        if (this.ˎ == null) {
            this.ˎ = LayoutInflater.from(getBaseContext()).cloneInContext(this);
        }
        return this.ˎ;
    }

    protected void ˏ(Theme theme, int i, boolean z) {
        theme.applyStyle(i, true);
    }

    private void ॱ() {
        boolean z = this.ˊ == null;
        if (z) {
            this.ˊ = getResources().newTheme();
            Theme theme = getBaseContext().getTheme();
            if (theme != null) {
                this.ˊ.setTo(theme);
            }
        }
        ˏ(this.ˊ, this.ॱ, z);
    }

    public AssetManager getAssets() {
        return getResources().getAssets();
    }
}
